home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / NANSI33.ARJ / NANSI.DOC < prev    next >
Text File  |  1991-11-29  |  28KB  |  991 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          NANSI.SYS
  8.              An Enhanced MS-DOS Console Driver
  9.                 Version 3.3   November 1991
  10.  
  11.  
  12.  
  13. 1.  Introduction - Who should use NANSI.SYS
  14.  
  15. NANSI.SYS is a console device driver for MS-DOS  computers.   It  exe-
  16. cutes the same ANSI cursor control sequences as does the standard con-
  17. sole driver  ANSI.SYS,  but  significantly  faster.   It  also  offers
  18. several extra features, while still being simple, small, and cheap.
  19.  
  20. You can benefit from using NANSI.SYS if:
  21. 1. you use programs (such as DIR, MORE, or NETHACK) which display text
  22. on the screen via DOS, or
  23. 2. you have an EGA or VGA, and want to use the 43- or 50-line mode  of
  24. your display, or
  25. 3. you run out of space when redefining keys with ANSI.SYS, or
  26. 4. you are a programmer who uses ANSI escape sequences, and are  frus-
  27. trated with slow display updates, or
  28. 5. you are porting display-intensive Unix programs to  run  under  MS-
  29. DOS.
  30.  
  31. You will not benefit from using NANSI.SYS if:
  32. 1. you never wish commands like TYPE or DIR were faster, and
  33. 2. you only use programs like Microsoft Word or  Word  Perfect,  which
  34. bypass DOS when displaying text, and
  35. 3. you aren't interested in displaying 43 lines of text on your EGA or
  36. VGA, and
  37. 4. you have never heard of ANSI.SYS anyway.
  38.  
  39. The display speed improvement you get by installing NANSI.SYS  depends
  40. on  the  kind of programs you run.  Installing NANSI.SYS will bring no
  41. improvement in display speed for programs that bypass DOS (e.g. Micro-
  42. soft Word), a 30% improvement in display speed with most programs that
  43. don't bypass DOS, a 50% improvement  with  "optimized"  programs  (see
  44. chapter 9 below), and a 95% improvement with "optimized" programs that
  45. avoid scrolling.
  46.  
  47. One "optimized" program, COPY /b, comes with DOS.  To test  the  speed
  48. improvement  yourself,  create  a  long  text  file named foo.txt, and
  49. display it with COPY /b foo.txt con: with NANSI.SYS installed- it will
  50. go by very quickly.  This speed increase occurs even when running in a
  51. window in Microsoft Windows 3.0.
  52.  
  53. 2.  Compatibility
  54.  
  55. NANSI.SYS has been tested on IBM PC/XT, /AT,  and  PS/2  systems.   It
  56. should  run  on any CGA, MDA, EGA, or VGA compatible video card. It is
  57. compatible with Microsoft Windows 3.0.  Unlike  many  display  speedup
  58. progams,  it  does not use wierd hardware scrolling tricks, and there-
  59. fore remains completely compatible with programs that  write  directly
  60. to the screen.
  61.  
  62.  
  63.  
  64.                           November 29, 1991
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                                 - 2 -
  71.  
  72.  
  73. 3.  Copyright status
  74.  
  75. This program and documentation is Copyright 1986, 1991  Daniel  Kegel.
  76. The  executable  program  and  its documentation may be freely distri-
  77. buted.
  78.  
  79. If you use this program for education or at home, you  are  encouraged
  80. to  send  a  US$10 donation to the author.  If you use it for business
  81. purposes, you are required to purchase a right-to-use license by send-
  82. ing US$10 to the author.
  83.  
  84. Copies of the driver on 360 KB floppy, together with printed  documen-
  85. tation,  may  be  obtained  from  the author for US$35.  Copies of the
  86. driver's source code are also available.
  87.  
  88. License fees, donations, and correspondence  (in  English  or  German)
  89. should be directed to the author at the following address:
  90.  
  91.         Daniel Kegel
  92.         535 E. Mendocino St.
  93.         Altadena, CA. 91001 USA
  94.  
  95. or at the Internet E-mail addresses
  96.  
  97.         dank@blacks.jpl.nasa.gov  or  dank@cco.caltech.edu
  98.  
  99.  
  100. 4.  Version
  101.  
  102. The version number can be found with the DOS command TYPE NANSI.SYS.
  103. This documentation is for version 3.3, created November 1991.
  104.  
  105. 5.  Installation and System Requirements
  106.  
  107. NANSI.SYS version 3.3 is distributed as the archive NANSI33.ZIP,  with
  108. the following contents:
  109.  
  110.         NANSI.SYS - the device driver
  111.         NANSI.DOC - this documentation file
  112.         RAW.C     - how to set and clear RAW mode for faster screen output
  113.         RAW.H     - definitions for users of RAW.C
  114.         GC.ON     - text file which, when TYPEd, turns on the graphics cursor
  115.  
  116.  
  117. NANSI.SYS requires MS-DOS version 2.0 or  higher,  and  uses  about  3
  118. kilobytes of system RAM.
  119.  
  120. To install NANSI.SYS on your computer, copy the file NANSI.SYS to your
  121. boot disk (usually C:), and include one of the following statements in
  122. the configuration file CONFIG.SYS on your boot disk:
  123. For IBM VGA and Vega VGA cards, or if you don't know  (or  care)  what
  124. kind of card you have:
  125.  
  126.         DEVICE=NANSI.SYS
  127.  
  128.  
  129.  
  130.                           November 29, 1991
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                                 - 3 -
  137.  
  138.  
  139. For Paradise VGA Plus cards:
  140.  
  141.         DEVICE=NANSI.SYS /t54 /t55 /t56 /t57
  142.  
  143. For VGA cards using the Oak Technology OTI-067:
  144.  
  145.         DEVICE=NANSI.SYS /t4F /t50 /t51
  146.  
  147. For VGA cards using the Trident Microsystems TVGA 8900:
  148.  
  149.         DEVICE=NANSI.SYS /t50 /t51 /t52 /t53 /t54 /t55 /t56 /t57 /t58 /t59 /t5A
  150.  
  151.  
  152. 6.  COMMAND-LINE OPTIONS
  153.  
  154.  
  155. 6.1.  /K   : force Nansi to use extended  keyboard  BIOS  calls  which
  156. sense F11 and F12
  157.  
  158. When IBM introduced the extended keyboard with F11 and F12  keys,  and
  159. separated  the  numeric keypad from the arrow keys, it also introduced
  160. an extended way of reading the keyboard with BIOS.  The old way  still
  161. works, but doesn't recognize the extended keys.
  162.  
  163. Normally, Nansi tries to detect whether  the  extended  keyboard  BIOS
  164. calls  are available, and if so, uses them.  However, by giving the /k
  165. option you can force Nansi to use these calls even  if  Nansi  doesn't
  166. think  they  are there. This option is included for compatibility with
  167. ANSI.SYS.
  168.  
  169. 6.2.  /X   : tell Nansi to let you redefine the extended keys indepen-
  170. dantly
  171.  
  172. IBM's extended keyboard BIOS calls added something  new:  they  return
  173. different  scan  codes  for different keys with the same meaning.  For
  174. instance, they return 71 for the numeric keypad HOME key,  but  224;71
  175. for the gray HOME key.  Nansi returns 71 when either of these keys are
  176. pressed.  However, the /X option causes these keys to be treated  dif-
  177. ferently  during  keyboard  redefinition.   For  example, if you start
  178. Nansi with the /X option, you can define just the gray HOME key to say
  179. "dir/w" by sending the string ESC [224;71;"dir/w";13p
  180.  
  181. 6.3.  /S   : tell Nansi to be secure, and disable  keyboard  redefini-
  182. tion
  183.  
  184. Although it is nice to be able to redefine the  keyboard  with  escape
  185. sequences,  it  is  a  gaping  security hole.  To prevent trojan horse
  186. attacks from messages in text files, archives, and programs downloaded
  187. from  the  outside  world, disable this feature by invoking Nansi with
  188. the /s option in config.sys.  For example,
  189.  
  190.         DEVICE=NANSI.SYS /s /t54 /t55 /t56 /t57
  191.  
  192. This saves a few bytes of memory, too.
  193.  
  194.  
  195.  
  196.                           November 29, 1991
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                                 - 4 -
  203.  
  204.  
  205. 6.4.  /Tnn : tell Nansi that video mode nn is a text mode
  206.  
  207. No two VGA cards seem to have the same set of video mode  codes.   The
  208. same  mode number can indicate a graphics mode on one card, and a text
  209. mode on another card.  Worse yet, BIOS can't tell  you  what  kind  of
  210. mode  it's  in.   This  is  a  problem because Nansi gets its speed by
  211. bypassing BIOS, which it can only do in text modes.
  212.  
  213. Nansi solves this dilemma by maintaining a 256-entry table, one  entry
  214. per  possible  video mode.  By default, the table says that only modes
  215. 0, 1, 2, 3, and 7 are text modes.  You can add new text modes with the
  216. /t  option.   For  instance, if modes D hex and 50 hex are text modes,
  217. you would invoke Nansi as follows:
  218.  
  219.         DEVICE=NANSI.SYS /t0D /t50
  220.  
  221.  
  222. How to tell whether you need /t:
  223. If your board is in a non-IBM text video mode (for instance,  mode  50
  224. hex),  and  you  haven't added /t50 after NANSI.SYS in CONFIG.SYS, the
  225. cursor will disappear after a CLS command, and the text output will be
  226. sluggish;  furthermore, if you turn on the graphics cursor (by TYPEing
  227. the file GC.ON which came with NANSI), the beginning and end of  every
  228. text line will be garbled.
  229.  
  230. How to tell whether you don't need /t:
  231. If you mistakenly specify a graphics mode  with  the  /t  option,  the
  232. display  will  be  garbled  while in that mode.  Get back to normal by
  233. typing MODE CO80 or rebooting, and remove the offending /t option from
  234. config.sys.
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.                           November 29, 1991
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                                 - 5 -
  269.  
  270.  
  271. 7.  ANSI Control Sequences
  272.  
  273. While putting text up on the screen, NANSI.SYS keeps a lookout for the
  274. escape  character  (chr(27), known as ESC); this character signals the
  275. start of a terminal control sequence.  Terminal control sequences fol-
  276. low the format
  277.     ESC [ param; param; ...; param cmd
  278. where
  279.     ESC is the escape character chr$(27).
  280.     [ is the left bracket character.
  281.     param is an ASCII decimal number, or a string in quotes.
  282.     cmd is a case-specific letter identifying the command.
  283. Usually, zero, one, or two parameters are given.   If  parameters  are
  284. omitted, they usually default to 1; however, some commands (KKR) treat
  285. the no-parameter case  specially.   Spaces  are  not  allowed  between
  286. parameters.
  287.  
  288. For example, both ESC[1;1H and ESC[H send the cursor to the home posi-
  289. tion (1,1), which is the upper left.
  290.  
  291. In general, if you ask the cursor to go beyond the edge of the screen,
  292. it goes to the appropriate edge.  (ANSI.SYS was not always so nice.)
  293.  
  294. The following C macro illustrates how one could print a  string  at  a
  295. given location on the screen:
  296.     #define printXY(x,y,s)  printf("%c[%d;%dH%s", 27, y, x, s);
  297.  
  298. Either single or double quotes may be used to quote  a  string.   Each
  299. character  inside a quoted string is equivalent to one numeric parame-
  300. ter.  Quoted strings are normally used only for the Keyboard Key Reas-
  301. signment command.
  302.  
  303. Each ANSI control sequence supported by NANSI.SYS is described  below.
  304. The descriptions follow the format
  305.  
  306. 7.0.1.  ABBREVIATED_NAME: what_to_send  LONG NAME
  307.  
  308. where ABBREVIATED_NAME is a short name for the sequence,  what_to_send
  309. tells  you  what  characters  make up the sequence, and LONG NAME is a
  310. long name for the sequence.
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                           November 29, 1991
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                                 - 6 -
  335.  
  336.  
  337. 7.1.  Sequences dealing with Cursor Positioning
  338.  
  339. 7.1.1.  CUP: ESC[#;#H  Cursor Position
  340.  
  341. Moves the cursor to the position specified  by  the  parameters.   The
  342. first parameter, y, specifies the row number; the second parameter, x,
  343. specifies the column number.  If no parameters are given,  the  cursor
  344. is moved to (1,1), the upper left corner of the screen.
  345.  
  346.  
  347. 7.1.2.  HVP: ESC[#;#f  Horizontal and Vertical Position
  348.  
  349. This is identical to Cursor Position.  Don't ask me why it exists.
  350.  
  351.  
  352. 7.1.3.  CUU: ESC[#A    Cursor Up
  353.  
  354. Moves the cursor up the given number of rows without changing its hor-
  355. izontal position.
  356.  
  357.  
  358. 7.1.4.  CUD: ESC[#B    Cursor Down
  359.  
  360. Moves the cursor down the given number of rows  without  changing  its
  361. horizontal position.
  362.  
  363.  
  364. 7.1.5.  CUF: ESC[#C    Cursor Forward
  365.  
  366. Moves the cursor right the given number of  columns  without  changing
  367. its vertical position.
  368.  
  369.  
  370. 7.1.6.  CUB: ESC[#D    Cursor Backward
  371.  
  372. Moves the cursor left the given number of columns without changing its
  373. vertical position.
  374.  
  375.  
  376. 7.1.7.  DSR: ESC[#n    Device Status, Report!
  377.  
  378. # must be 6.  The sequence ESC[6n causes the console driver to  output
  379. a CPR (Cursor Position Report) sequence.
  380.  
  381. Note: This sequence is not supported by the  ANSI.SYS  emulator  built
  382. into Microsoft Windows 1.x or 2.x.
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                           November 29, 1991
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                                 - 7 -
  401.  
  402.  
  403. 7.1.8.  CPR: ESC[#;#R  Cursor Position Report
  404.  
  405. The console driver  outputs  this  sequence  upon  reciept  of  a  DSR
  406. sequence.   The first parameter is the cursor's vertical position; the
  407. second parameter is the cursor's horizontal position.
  408.  
  409. Note: Contrary to the  MS-DOS  manual,  ANSI.SYS  outputs  a  carriage
  410. return  after  this  sequence.   NANSI.SYS  faithfully reproduces this
  411. quirk.
  412.  
  413. The resulting string can have up to eleven characters.   For  example,
  414. if   you  have  a  100-line  display  (wow),  and  the  cursor  is  at
  415. (x=132,y=100), the string will be ESC[132;100R followed by a  carriage
  416. return.
  417.  
  418. This should never be sent to the console driver.
  419.  
  420. Also note: This sequence is not supported  by  the  ANSI.SYS  emulator
  421. built into Microsoft Windows 1.x or 2.x.
  422.  
  423. Here is an example of how to use DSR/CPR to find  the  current  cursor
  424. position with the C language:
  425.  
  426.         /* Code fragment to get current cursor X and Y from console */
  427.         /* Be sure to disable line-buffering on stdin before calling */
  428.         int x, y, c;
  429.         printf("\033[6n");
  430.         fflush(stdout);
  431.         if (getchar() != '\033' || getchar() != '[')
  432.             abort("Console not responding to DSR?");
  433.         for (y=0; isdigit(c=getchar()); y=y*10+(c-'0'));
  434.         if (c != ';')
  435.             abort("Console CPR faulty?");
  436.         for (x=0; isdigit(c=getchar()); x=x*10+(c-'0'));
  437.         if (c != 'R')
  438.             abort("Console CPR faulty?");
  439.         #ifndef VT100
  440.             getchar();  /* ignore trailing CR */
  441.         #endif
  442.  
  443.  
  444. This can also be useful for sensing screen size.
  445.  
  446.  
  447. 7.1.9.  SCP: ESC[s      Save Cursor Position
  448.  
  449. Saves the cursor's X and Y locations in  an  internal  variable.   See
  450. RCP.
  451.  
  452.  
  453. 7.1.10.  RCP: ESC[u    Restore Cursor Position
  454.  
  455. Moves cursor to the position it held when the last  SCP  sequence  was
  456. received.
  457.  
  458.  
  459.  
  460.                           November 29, 1991
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                                 - 8 -
  467.  
  468.  
  469. 7.2.  Sequences that Edit the Display
  470.  
  471. 7.2.1.  ED: ESC[#J    Erase in Display
  472.  
  473. # must be 2.  Clears the entire screen.
  474.  
  475. Note: Contrary to the MS-DOS manual, ANSI.SYS also moves the cursor to
  476. the  upper  left corner of the screen.  Contrary to the ANSI standard,
  477. ANSI.SYS does not insist on # being 2.   NANSI.SYS  faithfully  repro-
  478. duces  these quirks.  (Version 2.2 of NANSI.SYS insisted on # being 2,
  479. and it caused compatibility problems with programs  that  ignored  the
  480. MS-DOS manual.  Sigh.)
  481.  
  482.  
  483. 7.2.2.  EL: ESC[K    Erase in Line
  484.  
  485. Deletes from the cursor to the end of the line.
  486.  
  487.  
  488. 7.2.3.  IL: ESC[#L    Insert Lines
  489.  
  490. The cursor line and all lines below it  move  down  #  lines,  leaving
  491. blank  space.   The  cursor  position  is unchanged.  The bottommost #
  492. lines are lost.
  493.  
  494. Note: This is not supported in ANSI.SYS.
  495.  
  496.  
  497. 7.2.4.  DL: ESC[#M    Delete Lines
  498.  
  499. The block of # lines at and below the cursor are  deleted;  all  lines
  500. below  them  move up # lines to fill in the gap, leaving # blank lines
  501. at the bottom of the screen.  The cursor position is unchanged.
  502.  
  503. Note: This is not supported in ANSI.SYS.
  504.  
  505.  
  506. 7.2.5.  ICH: ESC[#@    Insert Characters
  507.  
  508. The cursor character and all characters to the right of it move  right
  509. #  columns,  leaving  behind  blank  space.   The  cursor  position is
  510. unchanged.  The rightmost # characters on the line are lost.
  511.  
  512. Note: This is not supported in ANSI.SYS.
  513.  
  514.  
  515. 7.2.6.  DCH: ESC[#P    Delete Characters
  516.  
  517. The block of # characters at and  to  the  right  of  the  cursor  are
  518. deleted;  all characters to the right of it move left # columns, leav-
  519. ing behind blank space.  The cursor position is unchanged.
  520.  
  521. Note: This is not supported in ANSI.SYS.
  522.  
  523.  
  524.  
  525.  
  526.                           November 29, 1991
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                                 - 9 -
  533.  
  534.  
  535. 7.3.  Sequences that Set Modes
  536.  
  537. 7.3.1.  KKR: ESC["string"p   Keyboard Key Reassignment
  538.  
  539. The first char (or, for function keys, two chars) of the string  gives
  540. the  key  to  redefine; the rest of the string is the key's new value.
  541. To specify unprintable chars, give the ASCII value of the char outside
  542. of  quotes,  as  a  normal  parameter.  IBM function keys are two byte
  543. strings starting with zero.  For instance, ESC[0;59;"dir a:";13p rede-
  544. fines  function key 1 to have the value "dir a:" followed by the ENTER
  545. key.
  546.  
  547. There are about 500 bytes  available  to  hold  redefinition  strings.
  548. Once this space fills up, new strings are ignored.
  549.  
  550. To clear all definitions, send the string ESC[p.  (There was no way to
  551. do this in ANSI.SYS.)
  552.  
  553. This feature is a security risk, and  can  be  disabled  with  the  /s
  554. option  when  loading  Nansi  in config.sys.  See Command-line Options
  555. above.
  556.  
  557. Here's a table of the ASCII values of the common  function  keys;  for
  558. others,  see  the IBM Basic manual or the "IBM PS/2 and PC BIOS Inter-
  559. face Technical Reference," a steal at $80 from IBM (1-800-IBM-PCTB).
  560.  
  561.         F1  0;59        F2  0;60        F3  0;61        F4  0;62
  562.         F5  0;63        F6  0;64        F7  0;65        F8  0;66
  563.         F9  0;67        F10 0;68        F11 0;133       F12 0;134
  564.         HOME 0;71       END  0;79       PGUP 0;73       PGDN 0;81
  565.         INS  0;82       DEL  0;83       LEFT 0;75       RIGHT 0;77
  566.         UP   0;72       DOWN 0;80
  567.  
  568. When /X is given, the gray Insert, Delete, Home, End, PageUp,  PageDn,
  569. and  arrow keys on an Extended keyboard can be redefined separately by
  570. using 224 rather than 0 as the initial byte.
  571.  
  572.  
  573. 7.3.2.  SGR: ESC[#;#;...#m  Set Graphics Rendition
  574.  
  575. The Set Graphics Rendition command is used to  select  foreground  and
  576. background  colors  or  attributes.  When you use multiple parameters,
  577. they are executed in sequence, and the effects are cumulative.
  578.  
  579.         Attrib     Value
  580.             0      All attributes off (normal white on black)
  581.             1      Bold
  582.             4      Underline
  583.             5      Blink
  584.             7      Reverse Video
  585.             30-37  foreground black/red/green/yellow/blue/magenta/cyan/white
  586.             40-47  background black/red/green/yellow/blue/magenta/cyan/white
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                           November 29, 1991
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                                 - 10 -
  599.  
  600.  
  601. 7.3.3.  SM: ESC[=nh  Set Video Mode
  602.  
  603. This sequence selects one of the available video modes. The  IBM  BIOS
  604. supports  several  video modes; the codes given in the BIOS documenta-
  605. tion are used as parameters to  the  Set  Mode  command.   (In  bitmap
  606. modes, the cursor is simulated with a small blob (^V).)
  607.  
  608.             Mode Code           Value
  609.                 0               text 40x25 Black & White
  610.                 1               text 40x25 Color
  611.                 2               text 80x25 Black & White
  612.                 3               text 80x25 Color
  613.                 4               bitmap 320x200 4 bits/pixel
  614.                 5               bitmap 320x200 1 bit/pixel
  615.                 6               bitmap 640x200 1 bit/pixel
  616.                 13              bitmap 320x200 4 bits/pixel
  617.                 14              bitmap 640x200 4 bits/pixel
  618.                 15              bitmap 640x350 1 bit/pixel
  619.                 16              bitmap 640x350 4 bits/pixel
  620.                 17              bitmap 640x480 1 bit/pixel
  621.                 18              bitmap 640x480 4 bits/pixel
  622.                 19              bitmap 320x200 8 bits/pixel
  623.  
  624.  
  625. Modes 0, 1, and 4-19 require a CGA, EGA or VGA.
  626. Modes 13-16 require an EGA or VGA.
  627. Modes 17-19 require a VGA.
  628. Other graphics cards may support other video modes.
  629.  
  630. The EGA and VGA let you use a shorter character cell in text modes  in
  631. order to squeeze more lines of text out of the 25-line text modes.  To
  632. enter short line mode, set the desired 25-line text  mode  (0  to  3),
  633. then Set Mode 43.  For instance: ESC[=3h ESC[=43h.  To exit short line
  634. mode, set the desired 25-line text mode again.  On IBM VGA cards, this
  635. sequence gives you a 50 line screen.  NANSI.SYS ignores mode 43 unless
  636. there is an EGA or VGA on your computer.
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                           November 29, 1991
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                                 - 11 -
  665.  
  666.  
  667. 7.3.4.  SM: ESC[?nh  Set Nonvideo Mode
  668.  
  669. This sequence is used to set non-video modes.   The  only  value  sup-
  670. ported is
  671.  
  672.             Mode Code           Value when set
  673.                 7               Cursor wraps at end of line
  674.  
  675.  
  676. Setting mode 7 tells the cursor to wrap around to the next  line  when
  677. it passes the end of a line.
  678.  
  679. 7.3.5.  RM: ESC[?nl  Reset Nonvideo Mode
  680.  
  681. This sequence is used to reset non-video modes.  The only  value  sup-
  682. ported is
  683.  
  684.             Mode Code           Value when reset
  685.                 7               Cursor stops at end of line
  686.  
  687.  
  688. Resetting mode 7 tells the cursor to 'stick' at the end  of  the  line
  689. instead of wrapping to the next line.
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                           November 29, 1991
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                                 - 12 -
  731.  
  732.  
  733. 8.  Background - What does a console driver do, and how?
  734.  
  735. A console driver consists of subroutines which are called  by  MS-DOS.
  736. MS-DOS itself is mostly just subroutines which can be called by appli-
  737. cation programs.
  738.  
  739. Programs that want to display text on the screen can call the  "Write"
  740. subroutine  provided  by  MS-DOS.   This  subroutine in turn calls the
  741. "Write" subroutine of the console driver.
  742.  
  743. When you, for example, type
  744.     C> type foo.txt
  745. COMMAND.COM uses the "Read" subroutine of  MS-DOS  to  read  the  file
  746. "foo.txt" from the disk; it then uses the "Write" subroutine of MS-DOS
  747. with the file's contents.  MS-DOS  then  calls  the  console  driver's
  748. "Write" subroutine, which finally puts the data up on the screen.
  749.  
  750. Both ANSI.SYS and NANSI.SYS use IBM Video BIOS to control the  screen.
  751. However,  NANSI.SYS  writes directly to the screen in text modes; this
  752. allows much faster operation.
  753.  
  754.  
  755. 9.  How to Display Text Quickly
  756.  
  757. Output to the screen via DOS is usually slow  because  characters  are
  758. sent  one-at-a-time  through  several layers of software.  Application
  759. programs often call a DOS function for each character or line.
  760.  
  761. To avoid this overhead, application  programs  should  write  as  many
  762. characters  per  DOS call as possible (in C programs, this means using
  763. setbuf(), fflush(), and buffered output).
  764.  
  765. Another problem is that application programs sometimes send line after
  766. line  of  text,  letting  the cursor stay at the bottom of the screen.
  767. This forces the console driver to scroll the entire screen up once for
  768. each line displayed, which is rather expensive.
  769.  
  770. This can be fixed by having the application program clear  the  screen
  771. and home the cursor after each page of output.
  772.  
  773. Finally, the biggest problem is that DOS calls the device driver  once
  774. or twice for each character written.
  775.  
  776. Fortunately, DOS can be told to pass the entire write request directly
  777. to  the device driver; this is called "raw" mode.  The files RAW.C and
  778. RAW.H, included in this package, provide an easy way to set and  clear
  779. "raw"  mode, to turn break checking on and off, and to check for keys-
  780. trokes when in raw mode.
  781.  
  782. Even if you follow all these rules, output with ANSI.SYS will still be
  783. very  slow,  simply  because  IBM  did  a  bad job designing BIOS, and
  784. because ANSI.SYS was written with  total  disregard  for  performance.
  785. NANSI.SYS, on the other hand, was written by a performance fanatic.
  786.  
  787.  
  788.  
  789.  
  790.                           November 29, 1991
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                                 - 13 -
  797.  
  798.  
  799. 10.  NANSI and Microsoft Windows
  800.  
  801. Microsoft Windows 1.x and 2.x allowed you to run command.com in a win-
  802. dow,  but did not give you access to NANSI.SYS.  Windows 3.0 gives you
  803. full access to NANSI.SYS, even when running command.com  in  a  window
  804. (wow!).   However,  you  can only do this if you have a 386-based com-
  805. puter (boo, hiss); on other computers, Windows runs  command.com  only
  806. in full screen mode.
  807.  
  808. Under Microsoft Windows 3.0, if you write text to stdout in RAW  mode,
  809. the display is not refreshed until the end of the write; no intermedi-
  810. ate scrolling is shown.  I suspect this  is  because  Windows  doesn't
  811. refresh the display until display memory hasn't been touched for a few
  812. milliseconds.
  813.  
  814. 11.  New in version 3.3 of NANSI.SYS
  815.  
  816. Fixed bug that caused erratic behavior after ESC[p.  Bug  was  present
  817. in all prior versions of NANSI.
  818.  
  819. Fixed a few typos in documentation.
  820.  
  821. 12.  New in version 3.2 of NANSI.SYS
  822.  
  823. Can finally read F11 and F12!
  824.  
  825. New /K command-line option forces Nansi to use Extended Keyboard  BIOS
  826. calls  if  for  some  reason Nansi doesn't recognize the extended key-
  827. board.
  828.  
  829. New /X command-line option lets user redefine "new" cursor motion keys
  830. independently of "old" cursor motion keys.
  831.  
  832. Both of these switches are compatible with the switches  of  the  same
  833. name in ANSI.SYS.
  834.  
  835. 13.  New in version 3.1 of NANSI.SYS
  836.  
  837. A new escape sequence has been added to enable and disable  the  simu-
  838. lated  cursor in graphics mode (see SET MODE 99).  The graphics cursor
  839. is disabled by default.
  840.  
  841. Nansi can now sense options given  on  the  DEVICE=NANSI.SYS  line  in
  842. config.sys.
  843.  
  844. /S command-line option has been added to disable the keyboard redefin-
  845. ition escape sequence.  This closes up a big security loophole.
  846.  
  847. /T command-line option has been added to allow the user to tell  Nansi
  848. about  nonstandard  text video modes (see COMMAND-LINE OPTIONS).  This
  849. is important if you want to use non-IBM text modes properly, as  Nansi
  850. treats  nonstandard  modes  as  graphics  by default, which results in
  851. slower display.
  852.  
  853.  
  854.  
  855.  
  856.                           November 29, 1991
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                                 - 14 -
  863.  
  864.  
  865. 14.  New in version 3.0 of NANSI.SYS
  866.  
  867. Now obeys BIOS's idea of number of screen lines, when supported.
  868.  
  869. Works properly when on video pages greater than zero, too.
  870.  
  871. Supports 132-column displays.
  872.  
  873. Deleted Output Character Translation feature.  It took up  260  bytes,
  874. and nobody ever used it.
  875.  
  876. Fixed bug related to setting background color while in graphics mode.
  877.  
  878. No longer assumes AH is zero upon entry to driver.
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                           November 29, 1991
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                                 - 15 -
  929.  
  930.  
  931. 15.  Limitations in the current version of NANSI.SYS
  932.  
  933. Video modes are specified in hexadecimal on the command line,  and  in
  934. decimal  in  escape  sequences.  This is a needless inconsistancy, but
  935. since users' manuals usually specify  the  mode  numbers  in  hex,  it
  936. shouldn't  be  too big a bother.  You can convert a hexadecimal number
  937. to decimal in BASIC with the print command.  For example, from the DOS
  938. prompt, typing
  939.  
  940.         C:>basic
  941.         print &h7f
  942.         system
  943.  
  944. displays "127".
  945.  
  946. All parameter values must be between 0 and 255.
  947.  
  948. The maximum number of characters available for  keyboard  redefinition
  949. is  500.   Any  single  keyboard  redefinition escape sequence must be
  950. shorter than (500 - (total keyboard redefinition space already  used))
  951. bytes.
  952.  
  953. Insert and delete character do not work in graphics modes.
  954.  
  955. Graphics mode writing is slow.  If this bothers you, try NNANSI, which
  956. is someone else's modification of NANSI v2.2 to attack just this prob-
  957. lem.
  958.  
  959. Does not support erase-to-end-of-screen and other useful functions.
  960.  
  961. Nansi determines whether the BIOS number-of-screen-lines  variable  is
  962. supported by checking for an EGA card.  There might be a better way.
  963.  
  964. Nansi only checks for an EGA or VGA card at startup time.  If you have
  965. two  video  cards  installed, and one shows more text lines per screen
  966. than the other, AND you switch between the  cards  without  rebooting,
  967. Nansi could conceivably become confused about the number of text lines
  968. on the screen.
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.                           November 29, 1991
  989.  
  990.  
  991.